package com.bdqn.gulimall.seckill.service.impl;

import com.alibaba.fastjson.TypeReference;
import com.bdqn.common.utils.R;
import com.bdqn.gulimall.feign.CouponFeignService;
import com.bdqn.gulimall.seckill.service.SeckillService;
import com.bdqn.gulimall.vo.SeckillSessionWithSkus;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * SeckillServiceImpl
 *
 * @author f
 * @since 2022/3/11
 */
@Service
public class SeckillServiceImpl implements SeckillService {

    @Resource
    CouponFeignService couponFeignService;

    @Resource
    StringRedisTemplate redisTemplate;

    /**
     * 3天内上架的商品
     */
    @Override
    public void uploadSeckillSkuLatest3Days() {
        // 1.扫描最近3天需要参与秒杀活动的商品
        R session = couponFeignService.getLates3DaySession();
        if (session.getCode() == 0){
            //上架商品
            SeckillSessionWithSkus sessionData = session.getData(new TypeReference<SeckillSessionWithSkus>(){
            });

            //缓存到Redis
            // 1.缓存活动信息

            //2.缓存活动的关联商品信息
        }
    }

    private void saveSessionInfos(){

    }
}
